package com.ruoyi.passenger.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.passenger.domain.TbPassengerCar;
import com.ruoyi.passenger.service.ITbPassengerCarService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 乘客打车表Controller
 * 
 * @author ruoyi
 * @date 2025-08-26
 */
@RestController
@RequestMapping("/car")
public class TbPassengerCarController extends BaseController
{
    @Autowired
    private ITbPassengerCarService tbPassengerCarService;

    /**
     * 查询乘客打车表列表
     */
    //@RequiresPermissions("passenger:car:list")
    @GetMapping("/list")
    public TableDataInfo list(TbPassengerCar tbPassengerCar)
    {
        startPage();
        List<TbPassengerCar> list = tbPassengerCarService.selectTbPassengerCarList(tbPassengerCar);
        return getDataTable(list);
    }

    /**
     * 导出乘客打车表列表
     */
    //@RequiresPermissions("passenger:car:export")
    @Log(title = "乘客打车表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbPassengerCar tbPassengerCar)
    {
        List<TbPassengerCar> list = tbPassengerCarService.selectTbPassengerCarList(tbPassengerCar);
        ExcelUtil<TbPassengerCar> util = new ExcelUtil<TbPassengerCar>(TbPassengerCar.class);
        util.exportExcel(response, list, "乘客打车表数据");
    }

    /**
     * 获取乘客打车表详细信息
     */
    //@RequiresPermissions("passenger:car:query")
    @GetMapping(value = "/{passengerId}")
    public AjaxResult getInfo(@PathVariable("passengerId") Long passengerId)
    {
        return success(tbPassengerCarService.selectTbPassengerCarByPassengerId(passengerId));
    }

    /**
     * 新增乘客打车表
     */
    //@RequiresPermissions("passenger:car:add")
    @Log(title = "乘客打车表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbPassengerCar tbPassengerCar)
    {
        return toAjax(tbPassengerCarService.insertTbPassengerCar(tbPassengerCar));
    }

    /**
     * 修改乘客打车表
     */
    //@RequiresPermissions("passenger:car:edit")
    @Log(title = "乘客打车表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbPassengerCar tbPassengerCar)
    {
        return toAjax(tbPassengerCarService.updateTbPassengerCar(tbPassengerCar));
    }

    /**
     * 删除乘客打车表
     */
    //@RequiresPermissions("passenger:car:remove")
    @Log(title = "乘客打车表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{passengerIds}")
    public AjaxResult remove(@PathVariable Long[] passengerIds)
    {
        return toAjax(tbPassengerCarService.deleteTbPassengerCarByPassengerIds(passengerIds));
    }


}
